package com.ruoyi.web.controller.shortplay;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.shortplay.domain.VideoCoverKey;
import com.ruoyi.shortplay.service.IVideoCoverKeyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * AI封面关键字Controller
 *
 * @author ruoyi
 * @date 2025-11-18
 */
@RestController
@RequestMapping("/shortplay/coverkey")
public class VideoCoverKeyController extends BaseController {
    @Autowired
    private IVideoCoverKeyService videoCoverKeyService;

    /**
     * 查询AI封面关键字列表
     */
    @GetMapping("/list")
    public TableDataInfo list(VideoCoverKey videoCoverKey) {
        startPage();
        List<VideoCoverKey> list = videoCoverKeyService.selectVideoCoverKeyList(videoCoverKey);
        return getDataTable(list);
    }

    /**
     * 导出AI封面关键字列表
     */
    @Log(title = "AI封面关键字", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VideoCoverKey videoCoverKey) {
        List<VideoCoverKey> list = videoCoverKeyService.selectVideoCoverKeyList(videoCoverKey);
        ExcelUtil<VideoCoverKey> util = new ExcelUtil<VideoCoverKey>(VideoCoverKey.class);
        util.exportExcel(response, list, "AI封面关键字数据");
    }

    /**
     * 获取AI封面关键字详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(videoCoverKeyService.selectVideoCoverKeyById(id));
    }

    /**
     * 新增AI封面关键字
     */
    @Log(title = "AI封面关键字", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VideoCoverKey videoCoverKey) {
        return toAjax(videoCoverKeyService.insertVideoCoverKey(videoCoverKey));
    }

    /**
     * 修改AI封面关键字
     */
    @Log(title = "AI封面关键字", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VideoCoverKey videoCoverKey) {
        return toAjax(videoCoverKeyService.updateVideoCoverKey(videoCoverKey));
    }

    /**
     * 删除AI封面关键字
     */
    @Log(title = "AI封面关键字", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(videoCoverKeyService.deleteVideoCoverKeyByIds(ids));
    }
}
